package boogie.game.sprite;

import boogie.game.GameState;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;

/**
 *
 * @author Boogie
 */
public abstract class Sprite {
    private Point position;
    private Rectangle hitbox;
    public final GameState gameState;

    public Sprite(GameState gameState,int x,int y,int width,int height) {
        this(gameState,new Point(x,y),new Dimension(width,height));
    }

    public Sprite(GameState gameState, Point point,Dimension dimension) {
        this.gameState = gameState;
        this.position = point;
        hitbox = new Rectangle(point ,dimension);
        gameState.sprites.add(this);
    }
    
    
    public abstract void onUpdate();
    public abstract void onDraw(Graphics2D g);
    /**
     * Override to handle collision
     * @param s - Colliding sprite
     */
    public void onCollide(Sprite s){
    }

    public Rectangle getHitbox() {
        return hitbox;
    }

    public Point getPosition(){
        return position;
    }

    public void setPosition(int x,int y){
        this.setPosition(new Point(x,y));        
    }
    public void setPosition(Point p){
        this.position = p;
        hitbox.setLocation(p);
    }
    public int getX(){
        return position.x;
    }
    
    public int getY(){
        return position.y;
    }
    
    public int getWidth(){
        return hitbox.width;
    }
    public int getHeight(){
        return hitbox.height;
    }
    public Dimension getDimension(){
        return hitbox.getSize();
    }
}
